#include "free_queue.h"
#include <stdio.h>
#include <string.h>

int main() {
    if (!shm_lock_free_queue_init(128)) {
        fprintf(stderr, "Failed to initialize shared memory lock-free queue\n");
        return 1;
    }

    char data[128];
    for (int i = 0; i < 100; i++) {
        snprintf(data, sizeof(data), "Message %d", i);
        if (!shm_lock_free_queue_write(data, strlen(data) + 1)) {
            fprintf(stderr, "Failed to write data\n");
        } else {
            printf("Produced: %s\n", data);
        }
        sleep(1);
    }

    //shm_lock_free_queue_destroy();  // 显式销毁共享内存
    return 0;
}
